package cn.com.shadowless.xinning.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.com.shadowless.xinning.R;
import cn.com.shadowless.xinning.model.bill.BillCountInfo;

/**
 * The type Bill fragment adapter.
 *
 * @author sHadowLess
 */
public class BillFragmentLeftAdapter extends BaseQuickAdapter<BillCountInfo.DataBean, BaseViewHolder> {

    /**
     * Instantiates a new Bill fragment adapter.
     *
     * @param layoutResId the layout res id
     * @param data        the data
     */
    public BillFragmentLeftAdapter(int layoutResId, @Nullable List<BillCountInfo.DataBean> data) {
        super(layoutResId, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, BillCountInfo.DataBean item) {
        String orderName = item.getBillName();
        String unCheckNum = String.valueOf(item.getUnCheckCount());
        String formatOrderName = "%s(%s)";
        if ("0".equals(unCheckNum)) {
            helper.setText(R.id.bill_order_left_name, orderName);
        } else {
            helper.setText(R.id.bill_order_left_name, String.format(formatOrderName, orderName, unCheckNum));
        }
        helper.addOnClickListener(R.id.bill_order_left_item);
    }
}
